﻿<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../helpproject.xsl" ?>
<topic template="Default" lasteditedby="Geert" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../helpproject.xsd">
  <title translate="true">GyroscopeService</title>
  <keywords>
    <keyword translate="true">GyroscopeService</keyword>
    <keyword translate="true">IGyroscopeService</keyword>
    <keyword translate="true">MVVM</keyword>
    <keyword translate="true">Services</keyword>
  </keywords>
  <body>
    <header>
      <para styleclass="Heading1"><text styleclass="Heading1" translate="true">GyroscopeService</text></para>
    </header>
    <para styleclass="Notes"><text styleclass="Notes" translate="true">Note that the Gyroscope service is available as separate assembly to make sure Catel.MVVM does also work on older devices without a Gyroscope</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">The </text><text styleclass="Normal" style="font-style:italic;" translate="true">IGyroscopeService</text><text styleclass="Normal" translate="true"> allows a developer to access the gyroscope of a Windows Phone 7 Mango device.</text></para>
    <para styleclass="Notes"><text styleclass="Notes" translate="true">It is important that the service must be started and stopped to retrieve values</text></para>
    <para styleclass="Normal"><table styleclass="Default" rowcount="8" colcount="2">
      <tr style="vertical-align:top">
        <td style="width:181px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" style="font-weight:bold;" translate="true">Feature</text></para>
        </td>
        <td style="width:82px;">
          <para styleclass="Normal (list)" style="text-align:center;"><text styleclass="Normal (list)" style="font-weight:bold;" translate="true">Supported</text></para>
        </td>
      </tr>
      <tr style="vertical-align:top">
        <td style="width:181px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">WPF</text></para>
        </td>
        <td style="width:82px;">
          <para styleclass="Normal (list)" style="text-align:center;"><image src="notsupported.png" scale="100.00%" styleclass="Normal (list)"></image></para>
        </td>
      </tr>
      <tr style="vertical-align:top">
        <td style="width:181px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Silverlight 4</text></para>
        </td>
        <td style="width:82px;">
          <para styleclass="Normal (list)" style="text-align:center;"><image src="notsupported.png" scale="100.00%" styleclass="Normal (list)"></image></para>
        </td>
      </tr>
      <tr style="vertical-align:top">
        <td style="width:181px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Silverlight 5</text></para>
        </td>
        <td style="width:82px;">
          <para styleclass="Normal (list)" style="text-align:center;"><image src="notsupported.png" scale="100.00%" styleclass="Normal (list)"></image></para>
        </td>
      </tr>
      <tr style="vertical-align:top">
        <td style="width:181px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Windows Phone 7 Mango</text></para>
        </td>
        <td style="width:82px;">
          <para styleclass="Normal (list)" style="text-align:center;"><image src="supported.png" scale="100.00%" styleclass="Normal (list)"></image></para>
        </td>
      </tr>
      <tr style="vertical-align:top">
        <td style="width:181px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Windows Phone 8</text></para>
        </td>
        <td style="width:82px;">
          <para styleclass="Normal (list)" style="text-align:center;"><image src="notsupported.png" scale="100.00%" styleclass="Normal (list)"></image></para>
        </td>
      </tr>
      <tr style="vertical-align:top">
        <td style="width:181px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Windows RT</text></para>
        </td>
        <td style="width:82px;">
          <para styleclass="Normal (list)" style="text-align:center;"><image src="notsupported.png" scale="100.00%" styleclass="Normal (list)"></image></para>
        </td>
      </tr>
      <tr style="vertical-align:top">
        <td style="width:181px;">
          <para styleclass="Normal (list)"><text styleclass="Normal (list)" translate="true">Test/emulation service</text></para>
        </td>
        <td style="width:82px;">
          <para styleclass="Normal (list)" style="text-align:center;"><image src="supported.png" scale="100.00%" styleclass="Normal (list)"></image></para>
        </td>
      </tr>
    </table></para>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Check if the sensor is supported by the device</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">It is important to check whether the sensor is actually supported by the device. This can be done using the following code:</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">var gyroscopeService = GetService&lt;IGyroscopeService&gt;();</text><br/><text styleclass="Code Example" style="font-weight:bold; font-style:normal; color:#000080;" translate="true">if</text><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true"> (gyroscopeService.IsSupported)</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">{</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">    </text><text styleclass="Code Example" style="font-weight:normal; font-style:italic; color:#800000;" translate="true">// Sensor is supported</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">}</text></para>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Starting the service</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">When a service is started, the service will start raising the </text><link displaytype="text" defaultstyle="true" type="topiclink" href="E_Catel_MVVM_Services_ISensorService`2_CurrentValueChanged" styleclass="Normal" translate="true">CurrentValueChanged</link><text styleclass="Normal" translate="true"> event as soon as new values come in from the sensor. To start the service, use the following code:</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">var gyroscopeService = GetService&lt;IGyroscopeService&gt;();</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">gyroscopeService.CurrentValueChanged += OnGyroscopeValueChanged;</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">gyroscopeService.Start();</text></para>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Stopping the service</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">It is important to stop the service when it is no longer needed by the application. To stop the service, use the following code:</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">var gyroscopeService = GetService&lt;IGyroscopeService&gt;();</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">gyroscopeService.CurrentValueChanged -= OnGyroscopeValueChanged;</text><br/><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">gyroscopeService.Stop();</text></para>
  </body>
</topic>
